<%@ page import="java.util.*" contentType="text/html"%>
<%@ page import="model.Measurement" contentType="text/html"%>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>          
<script type="text/javascript">
	google.load('visualization', '1', {packages: ['corechart']});
	// VOOR HET TEKENEN VAN DE GRAFIEK
	
       function drawVisualization() {
            // Some raw data (not necessarily accurate)
            var luchtvochtigheid = 
              ['LuchtVochtigheid'];
         	  
            // Create and populate the data table.
            var data = new google.visualization.DataTable(); 
            data.addColumn('string', 'Year');
            data.addColumn('number', 'Vochtigheid');          
            
            <% 
            int dagen = 1;
            if(request.getAttribute("dagenVerschil") == null){
            } else{
            	  dagen = (Integer)request.getAttribute("dagenVerschil");
            }
          	  if(dagen != -1 && request.getAttribute("dagenLijst") != null && request.getAttribute("air") != null){
    		  			int[] urenWaardes = (int[])request.getAttribute("dagenLijst");
    		  			int[][] waardes = (int[][])request.getAttribute("air");
    		  		    dagen = (Integer)request.getAttribute("dagenVerschil");
    		  		    
    		  		    for(int x = 0; x < dagen; x++){
        	 	 			for(int i = 0; i<urenWaardes.length; i++){	%>
        						var date = '<%= urenWaardes[i] %>';
        	 					var getal = <%= waardes[x][i]%>;
        						data.addRows([[ date , getal]]  );
        	 	 	<%  }} 
	 	  }else if(request.getAttribute("dagenLijst") == null &&  !request.getAttribute("eersteKeer").equals("eersteKeer") && (Integer)request.getAttribute("keerGedaan") <1 ){
	 		  request.setAttribute("keerGedaan", (Integer)request.getAttribute("keerGedaan") +1 ); %>
	 		 alert("kan niet meer dan 28 dagen verschil zijn"); <%
	 	  } else if( !request.getAttribute("eersteKeer").equals("eersteKeer") && (Integer)request.getAttribute("keerGedaan") <1 ){
      	 	  request.setAttribute("keerGedaan", (Integer)request.getAttribute("keerGedaan") +1 ); %>
		alert("geen geldige invoer");
      	   <% } %>
            
            //Create and draw the visualization.
            var ac = new google.visualization.AreaChart(document.getElementById('airGraph'));
            ac.draw(data, {
              isStacked: true,
              width: 600,
              height: 400,
              vAxis: {title: 'Vochtigheid', minValue: 0, maxValue: 100},
              hAxis: {title: "Uren"}
            });
        	}
            
		google.setOnLoadCallback(drawVisualization);
      </script>